package org.example.petitionplatformsystem.service.Impl;

import org.example.petitionplatformsystem.dao.DuplicateAndFilterRepository;
import org.example.petitionplatformsystem.dao.model.DuplicateAndFilter;
import org.example.petitionplatformsystem.service.DuplicateAndFilterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DuplicateAndFilterServiceImpl implements DuplicateAndFilterService {
    @Autowired
    private DuplicateAndFilterRepository duplicateAndFilterRepository;

    @Override
    public void addDuplicateAndFilter(DuplicateAndFilter duplicateAndFilter) {
        duplicateAndFilterRepository.save(duplicateAndFilter);
    }

    @Override
    public void updateDuplicateAndFilter(DuplicateAndFilter duplicateAndFilter) {
        duplicateAndFilterRepository.save(duplicateAndFilter);
    }

    @Override
    public void deleteDuplicateAndFilter(DuplicateAndFilter duplicateAndFilter) {
        duplicateAndFilterRepository.delete(duplicateAndFilter);
    }

    @Override
    public DuplicateAndFilter getDuplicateAndFilterById(long id) {
        return duplicateAndFilterRepository.findById(id).orElse(null);
    }

    @Override
    public List<DuplicateAndFilter> getAllDuplicateAndFilters() {
        return duplicateAndFilterRepository.findAll();
    }
}
